package com.cll.learn.rpc.provider;

import com.cll.learn.rpc.provider.context.RpcProvider;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


/**
 * 描述信息:
 * 服务提供者启动引导类
 * @author CLL
 * @version 1.0
 * @date 2020/9/14 15:44
 */
@SpringBootApplication
public class ProviderBootstrap {

    private static final Logger logger = LoggerFactory.getLogger(ProviderBootstrap.class);

    public static void main(String[] args) throws InterruptedException {
        logger.info("===>>> 开始启动服务端");
        if (null != args && 1 == args.length && NumberUtils.isDigits(args[0])) {
            int port = Integer.parseInt(args[0]);
            SpringApplication.run(ProviderBootstrap.class);

            RpcProvider.startServer("127.0.0.1", port);

        } else {
            logger.error("****** 启动参数错误");
        }
    }
}